<template>
  <div>
    <div style="padding: 40px;">
      <table>
        <th>使用人名称</th>
        <th>登录账号</th>
        <th>登录密码</th>
        <th>所属门店</th>
        <th>权限角色</th>
        <th>状态</th>
        <th>操作</th>
        <tr v-for="item in data">
          <td>{{ item.textname }}</td>
          <td>{{ item.name }}</td>
          <td>{{ item.password }}</td>
          <td>{{ item.door }}</td>
          <td>{{ item.role }}</td>
          <td>
            {{ item.active == '1' ? '启用' : '禁用' }}
          </td>
          <td>
            <el-button type="text" @click="edit(item.id)">编辑</el-button>
            <el-button type="text" @click="del(item.id)">删除</el-button>
          </td>
        </tr>
      </table>
    </div>
  </div>
</template>
<script>
import { getLoginBx, DelLoginBx } from "../../utils/api"
export default {
  data() {
    return {
      data: []
    }
  },
  created() {
    this.render()
  },
  mounted() {
    this.render()
  },
  methods: {
    render() {
      getLoginBx().then(res => {
        this.data = res.data.data
      })
    },
    edit(i) {
      this.$router.push({
        path: '/limits/setAdmin',
        query: { id: i }
      })
    },
    del(i) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DelLoginBx({ id: i }).then(res => {
          if (res.status == 200) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.render()
          }
        })

      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });

    }

  }
}
</script>
<style scoped>
table {
  margin-top: 30px;
  border: 1px solid #777777;
  border-collapse: collapse;
  text-align: center;
  width: 100%;
  font-size: 14px;
}

tr {
  height: 50px;
}

td {
  width: 150px;
  border: 1px solid #777777;
}

th {
  height: 50px;
  line-height: 50px;
  font-weight: normal;
  background-color: #F6F6F6;
  border: 1px solid #777777;
}
</style>